<div class="container">
	<div id="innerMain">
					<div class="col-left" >
                    
                    <div class="view_breadcrumb" >
                    	<ul class="breadcrumb view_bread">
                        	<li><a href="<?php echo HOME; ?>"><i class="icon-home"></i> Home</a></li>
                            <li><a href="<?php echo url_category($data['category']['id'],$data['category']['alias']); ?>"><?php echo $data['category']['name']; ?></a></li>
                          
                        </ul>
                    
                    </div>
                    <div class="leftDetail">
						<div class="detail_view_image">
                        <div class="head_info">
                                  <h1><?php echo $data['post']['title'] ?></h1>
                                    <ul class="list-inline moreinfo" id="detail_top_info">
                                                <li><i class="icon-thumbs-up-alt"></i> <?php echo $data['post']['likes'] ?> Likes</li>
                                                <li><i class="icon-comments"></i> <?php echo $data['post']['comments'] ?> Comments</li>
                                                <li><i class="icon-eye-open"></i> <?php echo $data['post']['views'] ?> Views</li>
                                                <li class="pull-right view_time"><i class="icon-time"></i> <?php echo time_ago($data['post']['date_created']); ?></li>
                                               <li class="pull-right view_user"><a href="<?php echo url_user($data['post']['username']) ;?>"><i class="icon-user"></i> <?php echo $data['post']['username'] ?></a></li>
                                            </ul>
        
                                  <div class="clearfix"></div>
                          </div>
                          <div class="detail_popup_controller" id="popupControl-innerItem-<?= $data['post']['id']; ?>-image" data-href="<?= $data['post']['id']; ?>" data-rel="<?= $data['post']['type']; ?>">
	                          	<div class="wrap-fb-like-popup">
	                          		<span class="pull-left" style="padding:5px; font-size:15px; font-weight:bold; color:#399"><i class="icon-thumbs-up-alt"></i> Thích Và Share </span>
	                          		
                                   <div id="detail_like_fb" class="facebook-btn pull-left" style="width:200px; margin-top:5px; margin-left:5px">
                                    <div class="fb-like" data-href="<?= url_post($data['post']['id']); ?>" data-width="150" data-layout="button_count" data-action="like" data-show-faces="false" data-share="true"></div>
                                    </div>	
	                          		 
	                          		<div class="clr"></div>
	                          	</div>
	                          	<div class="controlNav">
		                          	<div class="btn-group pull-right">
		                          		<div class="controlNavLoading" style="display: none; float:left; margin:8px 5px 0px 0px;"><img class="" width="20" src="public/images/loading.gif" alt="loading" /></div>
								    	<button type="button" class="report_post btn btn-danger"  ><i class="icon-warning-sign"></i>Bài Viết Xấu</button>
								  		<button type="button" id="preNav" class="detail_controlNavItem btn btn-primary"  ><i class="icon-long-arrow-left"></i>Trước</button>
								  		<button type="button" id="nextNav" class="detail_controlNavItem btn btn-primary" > Sau <i class="icon-long-arrow-right"></i> </button>
								    </div>
	                          		
	                          	</div>
                          
                          	</div><!-- end .popupControl -->
                         
                         
                         

						  <input type="hidden" name="index_post_id" id="index_post_id" value="<?= $_GET['id'] ?>" />
								
						
				 					<div class="clearfix"></div>
									
                                    
									<p id="detail_description">
									
										<?php
										if($data['post']['type'] != 'text') 
											echo $data['post']['description']; 
										?>
										
									</p>
							
								<div id="detail_main_content" style="margin-top: 10px; padding:10px">
							
                            <?php if($data['post']['type']=='video'){ 
									  echo $data['post']['embed'];
							 }
							 ?>
                             
                             <?php if($data['post']['type']=='image'){ 
							 		  echo $data['post']['images_big'];
									
							 }?>
                             
								<?php if($data['post']['type']=='text'){ 
								?><div  style="padding: 10px;">
									<?php 	echo $data['post']['description'];?>
                                    </div>
							 <?php }?>
                                </div>
					
							
							<div class="clr"></div>

                             
						</div><!-- end .detail view image -->
				
                	<div style="height:20px"></div>
						<div id="fb-comment-box" class="facebook-comment col-md-12"><div class="fb-comments" data-href="<?= HOME . 'post/' . url_encode_post($data['post']['pid']) ?>"></div></div>
					
                    </div> <!-- End of leftDetail-->		
					</div><!-- end .col-md-9  -->
                    
                    
                    <!-- Start Right Block -->
                    <div class="col-right">
                              <?php
							
							   render_col_right('post',$data['album']) ?>   
                        
                                              
                    </div> <!-- End of md-colum-4 -->                    
                    <!-- End of Right Block -->
                    
                    
                    </div><!-- End of row -->
                    </div> <!-- End of container -->
							
					<script type="text/javascript">
						$(document).ready(function(){
							$('.clickShowView').click(function(e){
								e.preventDefault();
								$('.innerRightBlock').hide();
								
								task = $(this).attr('id');
								if($('#show_' + task).html().length){
									$('#show_' + task).fadeIn('normal');
								}else{
									$('#show_' + task).show();
									$('#show_' + task).append('<div id="rightShowLoading" class="loading"><div id="loadMoreItems" class="normalLoadBtn"><img width="20" src="public/images/loading.gif" alt="loading" /> Loading </div><div class="clr"></div></div>');
									$('#rightShowLoading').show();
									
									//$('#loading').show();
									$.ajax({
										url: '<?= BASE_URL ?>index.php?module=ajax&act=ajax&' + task + '=1',
										type : 'POST',
										success: function(data){
											if(data){
												$('#show_' + task).append(data).hide().fadeIn('slow');
												$('#rightShowLoading').remove();
											}else{
												$('#show_' + task).append('Đang cập nhật dữ liệu.');
												$('#rightShowLoading').remove();
											}
											
										}
									});
								}
							});

							$('.detail_popup_controller').sticky({topSpacing: 50});

							clicked = false;
							
							$('.detail_controlNavItem').live('click',function(e){
								
								if(clicked == true) return;
								if(clicked == false){
								$('.controlNavLoading').css('display','block');
								$('.head_info').css('opacity', '0.5');
								$('#detail_main_content').css('opacity', '0.5');
								
								
								nextOrPrev = $(this).attr('id');
								
								var iid = $('#index_post_id').val();
								
									clicked = true;
									$.ajax({
	
										url: '<?= BASE_URL; ?>index.php?module=ajax&act=ajax&detail_ajax_get_post=1&nav=' + nextOrPrev,
										type: 'POST',
										data: {id: iid},
										success: function(data){
											newData = JSON.parse(data);
											
											
											if(newData.post){
												
												if(newData.post.error_max_page == true){
													popupMessage('Thông báo', <?= json_encode($_SESSION['message']['last'] ? array($_SESSION['message']['last']) : array('Bạn đã xem hết bài viết. Quay lại trang chủ để xem bài mới nhất nhé!')); ?>, 'alert-info');
													$('.controlNavLoading').css('display','none');
													$('.head_info').css('opacity', '1');
													$('#detail_main_content').css('opacity', '1');
													//$('.controlNavLoading').css('display','none');
													return;
													
												}

												if(newData.post.error_min_page == true){
													popupMessage('Thông báo', <?= json_encode($_SESSION['message']['first'] ? array($_SESSION['message']['first']) : array('Bạn đang xem bài viết mới nhất rồi!'));?>, 'alert-info');
													$('.controlNavLoading').css('display','none');
													$('.head_info').css('opacity', '1');
													$('#detail_main_content').css('opacity', '1');
													//$('.controlNavLoading').css('display','none');
													return;
												}
												
												var userDetail = '';
												$('#index_post_id').val(newData.post.pid);
												$('.head_info h1').html(newData.post.title);
												
												$('.detail_popup_controller').attr('data-href', newData.post.id);
												$('.detail_popup_controller').attr('data-rel', newData.post.type);
												$('#detail_like_fb').html('<fb:like href="<?= HOME . 'post/' ?>'+newData.post.pid+'" send="true" layout="button" width="200" show_faces="false" font="" label="Post"></fb:like>');
												$('.facebook-comment').html('<div class="fb-comments" data-href="<?= HOME . 'post/' ?>'+newData.post.pid+'"></div>');
												
												$('#detail_top_info').html('<li>'+newData.post.likes+' Likes</li><li>'+newData.post.comments+' Comments</li><li>'+newData.post.views+' Views</li><li class="pull-right view_time">'+newData.post.date_created+'</li><li class="pull-right view_user">'+newData.post.username);
												if(newData.post.type != 'text'){
													if(newData.post.description != '' || newData.post.description != null){
														$('#detail_description').html(newData.post.description);
													}else{
														$('#detail_description').html('');
													}
												}
												
												$('#detail_main_content').html(newData.post.detail_main_content);
												$('.detail_view_user > .col-md-2').html('<img src="' + newData.post.user.avatar + '" alt="' + newData.post.username + '" class="img-responsive img-circle" />');
												userDetail += '<h4><a href="' + newData.post.user.link + '">' + newData.post.user.username + '</a></h4>';
												userDetail += '<p>' + newData.post.user.gioithieu + '</p>';
												userDetail += '<ul class="list-inline moreinfo" id="detail_bottom_info">'
												userDetail += '<li>' + newData.post.user.likes +' Likes</li>';
												userDetail += '<li>' + newData.post.user.views +' Views</li>';
												userDetail += '<li>' + newData.post.user.comments +' Comments</li>';
												userDetail += '<li>' + newData.post.user.post +' Posts</li>';
												userDetail += '<li>' + newData.post.user.album +' Albums</li>';
												userDetail += '</ul>';
												
												if(newData.post.user.facebook == 1){
													userDetail += '<span class="pull-left">';
													userDetail += '<a href="https://www.facebook.com/'+ newData.post.user.facebook_id +'>"><i class="icon-facebook"></i> Vist My Facebook</a>';
													userDetail += '</span>';
												}
												userDetail += '<span class="pull-right" style="color:#d35400">';
												userDetail += '<i class="icon-email"></i> ' + newData.post.user.email;
												userDetail += '</span><div class="clearfix"></div>';
	
												$('.detail_view_user > .col-md-10').html(userDetail);
												FB.XFBML.parse(document.getElementById('leftDetail'));
												$('.controlNavLoading').css('display','none');
												$('.head_info').css('opacity', '1');
												$('#detail_main_content').css('opacity', '1');
											}
											
											$('html, body').animate({
								                scrollTop:0
								            }, 300);
										},
									});
									clicked = false;
								}
							});

							
							// RESET POUP
							var curWidth; 
							   var detector;
							   detector = $('.leftDetail');
							   curWidth = detector.outerWidth(true);
								  curWidth = detector.outerWidth(true);
							   $('.detail_popup_controller').css('width', curWidth);
								  $(window).resize(function(){
							 if(detector.outerWidth(true)!=curWidth){
								curWidth = detector.outerWidth(true);
								
								  $('.detail_popup_controller').css('width', curWidth);
							 
							 }
								});
							//END RESET POPUP
							
						});

					</script>	

					
				